﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing.Design;
using System.Windows.Forms;
using System.ComponentModel.Design;
using UIDesigner.FieldHandlers.Bases;
using UIDesigner.DesignContainers;
using UIDesigner.Designers.Forms;

namespace UIDesigner.Editors
{
    public class FieldSpecEditor : UITypeEditor
    {
        public override UITypeEditorEditStyle GetEditStyle(System.ComponentModel.ITypeDescriptorContext context)
        {
            return UITypeEditorEditStyle.Modal;
        }

        public override object EditValue(System.ComponentModel.ITypeDescriptorContext context, IServiceProvider provider, object value)
        {
            Dictionary<string, FieldSpecification> rgSpecs = (Dictionary<string, FieldSpecification>) value;
            frmFieldSpecifications frm = new frmFieldSpecifications();
            ISelectionService objSelectionService = (ISelectionService)((IServiceProvider)context.Container).GetService(typeof(ISelectionService));
            object[] rgComponents = (object[])objSelectionService.GetSelectedComponents();
            ObjectControlContainer objContainer = (ObjectControlContainer)rgComponents[0];

            frm.Specifications = rgSpecs;
            frm.Construct = objContainer.Construct;

            if (frm.ShowDialog() == DialogResult.OK)
            {

            }

            return base.EditValue(context, provider, value);
        }
    }
}

